import Vue from 'vue'
import Router from 'vue-router'
import page from '@/components/page'
import news from '@/components/news'
import newsAll from '@/components/news/all'
import about from '@/components/about'
import about1 from '@/components/about/about1'
import about2 from '@/components/about/about2'
import about3 from '@/components/about/about3'
import project from '@/components/project'
import project1 from '@/components/project/project1'
import project2 from '@/components/project/project2'
import project3 from '@/components/project/project3'

Vue.use(Router)

export default new Router({
  routes: [{
      path: '/',
      name: 'page',
      component: page
    },
    {
      path: '/page/news',
      name: 'news',
      component: news,
      children: [{
        path: '/page/news/all',
        name: 'newsAll',
        component: newsAll,
      }]
    },
    {
      path: '/page/about',
      name: 'about',
      component: about,
      children: [{
          path: '/page/about/about1',
          name: 'about1',
          component: about1,
        },
        {
          path: '/page/about/about2',
          name: 'about2',
          component: about2,
        },
        {
          path: '/page/about/about3',
          name: 'about3',
          component: about3,
        }
      ]
    },
    {
      path: '/page/project',
      name: 'project',
      component: project,
      children: [{
          path: '/page/project/project1',
          name: 'project1',
          component: project1,
        },
        {
          path: '/page/project/project2',
          name: 'project2',
          component: project2,
        },
        {
          path: '/page/project/project3',
          name: 'project3',
          component: project3,
        }
      ]
    }
  ],
  //切换路由之后返回顶部
  scrollBehavior(to, from, savedPosition) {
    return { x: 0, y: 0 }
  }
})
